package com.ruoyi.shop.modules.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.shop.modules.domain.Attachment;
import com.ruoyi.shop.modules.mapper.AttachmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shop.modules.service.IAttachmentService;

/**
 * 文件Service业务层处理
 * 
 * @author 朱津辰
 * @date 2024-05-22
 */
@Service
public class AttachmentServiceImpl implements IAttachmentService 
{
    @Autowired
    private AttachmentMapper attachmentMapper;

    /**
     * 查询文件
     * 
     * @param id 文件主键
     * @return 文件
     */
    @Override
    public Attachment selectAttachmentById(String id)
    {
        return attachmentMapper.selectAttachmentById(id);
    }

    @Override
    public Attachment selectAttachmentByMD5(String md5) {
        return attachmentMapper.selectAttachmentByMD5(md5);
    }

    /**
     * 查询文件列表
     * 
     * @param attachment 文件
     * @return 文件
     */
    @Override
    public List<Attachment> selectAttachmentList(Attachment attachment)
    {
        return attachmentMapper.selectAttachmentList(attachment);
    }

    /**
     * 新增文件
     * 
     * @param attachment 文件
     * @return 结果
     */
    @Override
    public int insertAttachment(Attachment attachment)
    {
        attachment.setCreateTime(DateUtils.getNowDate());
        return attachmentMapper.insertAttachment(attachment);
    }

    /**
     * 修改文件
     * 
     * @param attachment 文件
     * @return 结果
     */
    @Override
    public int updateAttachment(Attachment attachment)
    {
        attachment.setUpdateTime(DateUtils.getNowDate());
        return attachmentMapper.updateAttachment(attachment);
    }

    /**
     * 批量删除文件
     * 
     * @param ids 需要删除的文件主键
     * @return 结果
     */
    @Override
    public int deleteAttachmentByIds(String[] ids)
    {
        return attachmentMapper.deleteAttachmentByIds(ids);
    }

    /**
     * 删除文件信息
     * 
     * @param id 文件主键
     * @return 结果
     */
    @Override
    public int deleteAttachmentById(String id)
    {
        return attachmentMapper.deleteAttachmentById(id);
    }
}
